<?php echo $this->fetch('header.html'); ?>
<style>
.order_form{color:#333; width:875px;}
.kdorder_add {background:#dddddd; margin-bottom:15px;}
.kdorder_add td{padding:8px;font-size:13px; background:#FFF}
.kdorder_add .select_class {border: 1px #CCC solid;height: 26px; border-radius:2px}
.kdorder_add .title_h1 {font-size:15px; color:#333; background:#d8ecfc; font-family:'Microsoft Yahei'}
.kdorder_add .title_h2 {text-align:right; width:120px; font-weight:bold;font-family:'Microsoft Yahei'}
.inputBorder{border: 1px #CCC solid;height: 20px;line-height: 20px;padding: 2px 4px; width:70px}
.botton_submit {border:0;background:#ed5736;height:35px;width:120px;text-align:center;line-height:35px;font-family:"Microsoft YaHei";font-size:15px;color:#fff;cursor:pointer;border-radius:4px; margin-right:10px}
.fuwu_xz {list-style:none; width:100%; overflow:hidden}
.fuwu_xz li {float:left;width:200px;line-height:22px;}
</style>
<div id="rightTop">
  <ul class="subnav">
    <li><a class="btn1" href="index.php?app=kd_order">运单列表</a></li>
    <li><a class="btn1" href="index.php?app=kd_order&act=add">添加运单</a></li>
    <li><a class="btn0" href="index.php?app=kd_order&act=feiyong&order_id=<?php echo $this->_var['order_info']['order_id']; ?>">费用计算</a></li>
    <li><?php if ($this->_var['order_info']['user_name']): ?>所属会员：<a href="index.php?app=user&act=index&field_name=user_name&field_value=<?php echo $this->_var['order_info']['user_name']; ?>" target="_blank" style="color:#00F"><?php echo $this->_var['order_info']['user_name']; ?></a><?php endif; ?></li>
  </ul>
</div>
<div class="content" style="padding:10px;">
<div class="order_form">
<form action="" method="post" id="form_box">
  <table cellspacing="1" width="100%" class="kdorder_add">
    <tr><td colspan="4" class="title_h1">&nbsp;基本信息</td></tr>
    <tr>
      <td class="title_h2" style="background:#FBFBFB">订单号：</td>
      <td><?php echo $this->_var['order_info']['order_sn']; ?></td>
      <td class="title_h2" style="background:#FBFBFB">快递单号：</td>
      <td><?php echo $this->_var['order_info']['express']; ?> <a href="<?php echo $this->_var['site_url']; ?>/<?php echo url('app=kd_order&ydh=' . $this->_var['order_info']['yundanhao']. ''); ?>" target="_blank" ><?php echo $this->_var['order_info']['yundanhao']; ?></a></td>
    </tr><tr>
      <td class="title_h2" style="background:#FBFBFB">订单状态：</td>
      <td><?php if ($this->_var['order_info']['status'] == '0'): ?><font color="#f00">未入库</font>
          <?php elseif ($this->_var['order_info']['status'] == '1'): ?><font color="#FF9900">部分入库</font>
          <?php elseif ($this->_var['order_info']['status'] == '2'): ?><font color="#009966">已入库</font>
          <?php elseif ($this->_var['order_info']['status'] == '3'): ?><font color="#00f">待付款</font>
          <?php elseif ($this->_var['order_info']['status'] == '5'): ?><font color="#3399CC">已付款</font>
          <?php elseif ($this->_var['order_info']['status'] == '6'): ?><font color="#FF00FF">待发货</font>
          <?php elseif ($this->_var['order_info']['status'] == '7'): ?><font color="#336600">已发货</font>
          <?php elseif ($this->_var['order_info']['status'] == '8'): ?>已完成
          <?php elseif ($this->_var['order_info']['status'] == '9'): ?><font color="#999">已取消</font>
          <?php endif; ?></td>
      <td class="title_h2" style="background:#FBFBFB">下单日期：</td>
      <td><?php echo local_date("Y-m-d H:i:s",$this->_var['order_info']['addtime']); ?></td>
    </tr>
  </table>    
  <table cellspacing="1" width="100%" class="kdorder_add">
    <tr>
      <td colspan="2" class="title_h1">运单费用明细</td></tr>
    <tr>
      <td valign="top" class="title_h2">包裹详细：</td>
      <td style="padding-bottom:0">
      <?php $_from = $this->_var['order_info']['goodswupin']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'wupin');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['wupin']):
?>
      <p style="background:#FFFFEF;padding:8px;margin-bottom:8px;border:1px solid #e1e1e1; line-height:180%">
        <input type="hidden" name="yubao_id[]" id="yubao_id" value="<?php echo $this->_var['wupin']['yubao_id']; ?>"/>
        <?php if ($this->_var['wupin']['PostOfficeID']): ?><?php echo $this->_var['wupin']['PostOfficeID']; ?>：<?php endif; ?><?php echo $this->_var['wupin']['yundanhao']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
        <?php echo ($this->_var['wupin']['GoodsName'] == '') ? '-' : $this->_var['wupin']['GoodsName']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
        数量：<?php echo ($this->_var['wupin']['GoodsCount'] == '') ? '0' : $this->_var['wupin']['GoodsCount']; ?>&nbsp;&nbsp;&nbsp;&nbsp;
        申报价值：$<?php echo ($this->_var['wupin']['GoodsWorth'] == '') ? '0' : $this->_var['wupin']['GoodsWorth']; ?> 美元<br />
        包裹重量：<input type="input" id="GoodsWeight" name="GoodsWeight[]" size="4" rel="80" onkeyup="clearNoNum(this)" value="<?php echo ($this->_var['wupin']['GoodsWeight'] == '') ? '0' : $this->_var['wupin']['GoodsWeight']; ?>" /> (LBS)&nbsp;&nbsp;
        长：<input type="text" id="GoodsLength" name="GoodsLength[]" size="3" rel="80" onkeyup="clearNoNum(this)" value="<?php echo ($this->_var['wupin']['GoodsLength'] == '') ? '0' : $this->_var['wupin']['GoodsLength']; ?>" />&nbsp;&nbsp;
        宽：<input type="text" id="GoodsWidth" name="GoodsWidth[]" size="3" rel="80" onkeyup="clearNoNum(this)" value="<?php echo ($this->_var['wupin']['GoodsWidth'] == '') ? '0' : $this->_var['wupin']['GoodsWidth']; ?>" />&nbsp;&nbsp;
        高：<input type="text" id="GoodsHeight" name="GoodsHeight[]" size="3" rel="80" onkeyup="clearNoNum(this)" value="<?php echo ($this->_var['wupin']['GoodsHeight'] == '') ? '0' : $this->_var['wupin']['GoodsHeight']; ?>" /> (cm³)
      </p>
      <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
      </td>
    </tr>    
    <tr>
      <td valign="top" class="title_h2">增值服务：</td>
      <td>
      <ul class="fuwu_xz">
       <?php $_from = $this->_var['fuwu_data']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['list']):
?>
       <?php if ($this->_var['list']['check'] > 0): ?><li>（√）<?php echo $this->_var['list']['title']; ?> <font color="#FF0000">$<?php echo $this->_var['list']['amount']; ?></font>/<?php echo $this->_var['list']['link']; ?></li><?php endif; ?>
       <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
       </ul>
       <?php if ($this->_var['ServiceItems']['Fix']['0'] > 0): ?><p style="line-height:22px">（√）小件物品单件加固 <font color="#FF0000">$<?php echo $this->_var['fuwu_data']['10']['amount']; ?>/</font><?php echo $this->_var['fuwu_data']['10']['link']; ?>&nbsp;&nbsp;加固数量：<?php echo $this->_var['ServiceItems']['Fix']['1']; ?>&nbsp;&nbsp;加固物品说明：<?php echo $this->_var['ServiceItems']['Fix']['2']; ?></p><?php endif; ?>
       <?php if ($this->_var['ServiceItems']['Bx']['0'] > 0): ?><p style="line-height:22px">（√）保险&nbsp;&nbsp;保价金额：$<?php echo $this->_var['ServiceItems']['Bx']['1']; ?></p><?php endif; ?>      
      </td>
    </tr>
    <tr>
      <td class="title_h2">增值服务费：</td>
      <td>$ <input name="fuwufei" type="text" value="<?php echo ($this->_var['order_info']['fuwufei'] == '') ? '0' : $this->_var['order_info']['fuwufei']; ?>" id="fuwufei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元 </td>
    </tr>    
    <tr>
      <td class="title_h2">运费：</td>
      <td>$ <input name="yunfei" type="text" value="<?php echo ($this->_var['order_info']['yunfei'] == '') ? '0' : $this->_var['order_info']['yunfei']; ?>" id="yunfei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元 <font color="#999">（包括基础运费+体积重费用）</font></td>
    </tr>
    <tr>
      <td class="title_h2">保险费：</td>
      <td>$ <input name="baoxianfei" type="text" value="<?php echo ($this->_var['order_info']['baoxianfei'] == '') ? '0' : $this->_var['order_info']['baoxianfei']; ?>" id="baoxianfei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元</td>
    </tr>
    <tr>
      <td class="title_h2">仓库操作费：</td>
      <td>$ <input name="caozuofei" type="text" value="<?php echo ($this->_var['order_info']['caozuofei'] == '') ? '0' : $this->_var['order_info']['caozuofei']; ?>" id="caozuofei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元</td>
    </tr>
    <tr>
      <td class="title_h2">仓储费：</td>
      <td>$ <input name="cangchufei" type="text" value="<?php echo ($this->_var['order_info']['cangchufei'] == '') ? '0' : $this->_var['order_info']['cangchufei']; ?>" id="cangchufei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元 </td>
    </tr>
    <tr>
      <td class="title_h2">关税：</td>
      <td>$ <input name="guanshuifei" type="text" value="<?php echo ($this->_var['order_info']['guanshuifei'] == '') ? '0' : $this->_var['order_info']['guanshuifei']; ?>" id="guanshuifei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元</td>
    </tr>
    <tr>
      <td class="title_h2">其它费用：</td>
      <td>$ <input name="qitafei" type="text" value="<?php echo ($this->_var['order_info']['qitafei'] == '') ? '0' : $this->_var['order_info']['qitafei']; ?>" id="qitafei" class="inputBorder cal_input" onkeyup="clearNoNum(this)"/> 美元 <font color="#999">（如果有其它额外费用产生，请在此设置。）</font></td>
    </tr>
    <tr>
      <td class="title_h2" style="color:#F00">共需支付：</td>
      <td style="color:#F00">$ <input name="totalfei" type="text" value="<?php echo ($this->_var['order_info']['totalfei'] == '') ? '0' : $this->_var['order_info']['totalfei']; ?>" id="totalfei" class="inputBorder" onkeyup="clearNoNum(this)"/> 美元。</td>
    </tr>
    <tr>
      <td class="title_h2" valign="top">费用说明：</td>
      <td><textarea name="Memo_fei" id="Memo_fei" style="border:1px solid #E8E8E8;width:55%;height:27px;padding:8px;font-size:12px;" placeholder="费用说明会显示到前台的会员查看，请认真正确填写"><?php echo $this->_var['order_info']['Memo_fei']; ?></textarea></td>
    </tr>
    <tr>
      <td class="title_h2" valign="top">运单状态：</td>
      <td><select name="status" class="select_class">
	<option value="0" <?php if ($this->_var['order_info']['status'] == '0'): ?>selected="selected"<?php endif; ?>>未入库</option>
    <option value="1" <?php if ($this->_var['order_info']['status'] == '1'): ?>selected="selected"<?php endif; ?>>部分入库</option>
	<option value="2" <?php if ($this->_var['order_info']['status'] == '2'): ?>selected="selected"<?php endif; ?>>已入库</option>
    <option value="3" <?php if ($this->_var['order_info']['status'] == '3'): ?>selected="selected"<?php endif; ?>>待付款</option>
    <option value="5" <?php if ($this->_var['order_info']['status'] == '5'): ?>selected="selected"<?php endif; ?>>已付款</option> 
    <option value="6" <?php if ($this->_var['order_info']['status'] == '6'): ?>selected="selected"<?php endif; ?>>待发货</option>
    <option value="7" <?php if ($this->_var['order_info']['status'] == '7'): ?>selected="selected"<?php endif; ?>>已发货</option>  
    <option value="8" <?php if ($this->_var['order_info']['status'] == '8'): ?>selected="selected"<?php endif; ?>>已完成</option>
    <option value="9" <?php if ($this->_var['order_info']['status'] == '9'): ?>selected="selected"<?php endif; ?>>已取消</option>  
	</select>
    <font color="#999">（价格填写完成后，建议把状态修改为：待付款、已付款）</font>
    </td>
    </tr>    
    <tr>
      <td></td>
      <td>
    <input type="button" name="imgButton" class="botton_submit" value="确认提交" onclick="return Check_form();" />
    <input type="button" name="imgButton" class="botton_submit" value="返回一页" onclick="history.go(-1)" style="background:#999"/>
    <input type="hidden" name="http_referer" value="<?php echo($_SERVER['HTTP_REFERER']); ?>"/>
    <?php if ($this->_var['order_info']['order_id']): ?>
    <input type="hidden" id="order_id" name="order_id" value="<?php echo $this->_var['order_info']['order_id']; ?>"/><input type="hidden" name="act"  value="feiyong"/>
    <?php endif; ?>
      </td>
    </tr>         
  </table>  
  <?php if ($this->_var['order_info']['Memo']): ?>
  <table width="100%" cellspacing="1" class="kdorder_add">
    <tr><td class="title_h1">&nbsp;客户运单备注</td></tr>
    <tr><td><?php echo $this->_var['order_info']['Memo']; ?></td></tr>
  </table> 
  <?php endif; ?>
</form>  
</div>
<script type="text/javascript">
$(document).ready(function(){
  $("input.cal_input").blur(function () {
	  var val = $(this).val();
	  if (!val) {
		  alert("请务必填写正确的金额（只能为数字）！");
		  $(this).val("0");
		  $(this).focus().select();
	  }
	  js_total();
  });	
  js_total();
});
function Check_form() {
  if ($("#totalfei").val()<=0) {alert("共需支付费用不能空");$("#totalfei").focus().select(); return false;}
  $("#form_box").submit();
}
//统计总费用
function js_total() {
    var fuwufei = parseFloat($("#fuwufei").val()); //服务费
    var yunfei = parseFloat($("#yunfei").val()); //运费
    var baoxianfei = parseFloat($("#baoxianfei").val()); //保险费
    var caozuofei = parseFloat($("#caozuofei").val()); //仓库操作费
    var cangchufei = parseFloat($("#cangchufei").val()); //仓储费
    var guanshuifei = parseFloat($("#guanshuifei").val()); //关税
    var qitafei = parseFloat($("#qitafei").val()); //其他费
    var totalfei = (fuwufei + yunfei + baoxianfei + caozuofei + cangchufei + guanshuifei + qitafei).toFixed(2); //总费用

    $("#totalfei").val(totalfei);
}
</script>
<div class="clear"></div>
</div>
<?php echo $this->fetch('footer.html'); ?>